package com.campus.wall.ui;

import android.content.Intent;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.campus.wall.R;
import com.campus.wall.adapter.LeaveMessageAdapter;
import com.campus.wall.base.BaseMvpActivity;
import com.campus.wall.contract.LeaveMessageContract;
import com.campus.wall.presenter.LeaveMessagePresenter;
import com.campus.wall.response.MessageResponse;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;


public class LeaveMessageActivity extends BaseMvpActivity<LeaveMessagePresenter> implements LeaveMessageContract.View {

    @BindView(R.id.rv_list)
    RecyclerView rv_list;
    private List<MessageResponse> list=new ArrayList<>();
    private LeaveMessageAdapter mAdapter;
    private LinearLayoutManager mLinearLayoutManager;
    @Override
    public int getLayoutId() {
        return R.layout.layout_leave_message;
    }

    @Override
    public void initView() {
        mPresenter = new LeaveMessagePresenter(this);
        mPresenter.attachView(this);
        mLinearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        list=mPresenter.initeMess();
        if(mAdapter==null){
            mAdapter = new LeaveMessageAdapter(list,this);
            rv_list.setLayoutManager(mLinearLayoutManager);
            rv_list.setAdapter(mAdapter);
        }else {
            mAdapter.notifyDataSetChanged();
        }
    }

    @OnClick(R.id.btn_back)
    void btn_back(){
        this.finish();
    }
    @OnClick(R.id.add_btn)
    void add_btn(){
        Intent intent = new Intent(this, AddMessageActivity.class);
        startActivity(intent);
    }

    @Override
    public void onSuccess() {

    }


}
